// exceptions header for threads library
#ifndef _DINKUM_THREADS_EXCEPTIONS
#define _DINKUM_THREADS_EXCEPTIONS
#include <stdexcept>
#include <Dinkum/threads/threads.h>

_STD_BEGIN
_CRTIMP2P _NO_RET(_PCDECL _Xbad_alloc());
_STD_END

namespace Dinkum
	{	// Dinkum Libraries
	namespace threads
		{	// Dinkum C++ Threads Library

class lock_error
	: public _STD runtime_error
	{	// lock error exception
public:
	lock_error()
		: _STD runtime_error("lock error")
		{	// default construct
		}
	};

class thread_resource_error
	: public _STD runtime_error
	{	// resource error exception
public:
	thread_resource_error()
		: _STD runtime_error("thread resource error")
		{	// default construct
		}
	};

_CRTIMP2P void _CDECL _Throw_lock_error();
_CRTIMP2P void _CDECL _Throw_resource_error();

inline int _Validate(int _Res)
	{	// convert error code to exception
	if (_Res == thrd_nomem)
		_STD _Xbad_alloc();
	else if (_Res == thrd_error)
		_Throw_resource_error();
	return (_Res);
	}
		}	// namespace threads
	}	// namespace Dinkum
#endif /* _DINKUM_THREADS_EXCEPTIONS */

/*
 * This file is derived from software bearing the following
 * restrictions:
 *
 * (c) Copyright William E. Kempf 2001
 *
 * Permission to use, copy, modify, distribute and sell this
 * software and its documentation for any purpose is hereby
 * granted without fee, provided that the above copyright
 * notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting
 * documentation. William E. Kempf makes no representations
 * about the suitability of this software for any purpose.
 * It is provided "as is" without express or implied warranty.
 */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V6.50:1422 */
